/* 
 * Enterprise Library Extensions - DI + ORM.
 * Copyright (C) 2006
 *
 * GNU General Public License
 *
 * This program is free software; you can redistribute 
 * it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 */
using System;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

namespace ELE.EnterpriseLibrary.Data.Configuration
{
  /// <summary>
  /// Configuration data used to overwrite the property bindings of an object mapping
  /// in a reference mapping of a query.
  /// <para>For example:</para>
  /// <code>
  /// &lt;queries>
  ///  &lt;add name="GetEmployeeById" 
  ///         sql="select id, name, addressId, birthDate from employee e, employee_extra ee where e.id=@Id and ee.employeeId = e.id">
  ///    &lt;mappings>
  ///      &lt;add name="Mapping1" objectId="Employee">
  ///        &lt;bindings>
  ///          &lt;add name="Age" ignore="true"/>
  ///        &lt;/bindings>
  ///      &lt;/add>
  ///    &lt;/mappings>
  ///  &lt;/add>
  /// &lt;/queries>
  /// </code>
  /// <para>In this case there is a property binding overwrite of Mapping1.Employee used for inputs and/or 
  /// results of the GetEmployeeById query, that simply ignores any binding to Age.</para>
  /// </summary>
  public class PropertyBindingOverwriteData : BasePropertyBindingData
  {
    private const string directionProperty = "direction";
    /// <summary>
    /// 
    /// </summary>
    public PropertyBindingOverwriteData() { }
    /// <summary>
    /// Constructor with the name of the property binding to overwrite.
    /// </summary>
    /// <param name="name"></param>
    public PropertyBindingOverwriteData(string name) : base(name) { }

    /// <summary>
    /// The id of the object that is to be mapped from the query's inputs or results.
    /// </summary>
    [ConfigurationProperty(directionProperty, IsRequired = false)]
    public string Direction
    {
      get { return (string)base[directionProperty]; }
      set { base[directionProperty] = value; }
    }
  }
}
